#ifndef GPIO_H
#define GPIO_H

#include <QObject>

enum DirectionType
{
    Input,
    OutPut
};

enum ActiveLowType
{
    NoFlip,
    Flip
};

enum ValueType
{
    L = 0,
    H
};

class GPIO : public QObject
{
    Q_OBJECT
public:
    explicit GPIO(int A = 0, int B = 0, QObject *parent = nullptr);

    int       Configuration(DirectionType direction, ActiveLowType activelow);
    void      SetValue(ValueType value);
    ValueType ReadValue(void);

private:
    /***********************************************************************/
    int Pins(int A, int B);

    //函数声明
    int gpioExport(int pin);
    int gpioUnexport(int pin);
    int gpioSetDirection(int pin, int direction);
    int gpioReadDirection(int pin, char *dir);
    int gpioSetValue(int pin, int value);
    int gpioReadValue(int pin);
    int gpioSetEdge(int pin, int edge);
    int gpioReadEdge(int pin, char *edge);
    int gpioSetActiveLow(int pin, int low);
    int gpioReadActiveLow(int pin);
    int gpioGetState(int pin, char *dir);

    //函数声明:有依赖
    int gpioOpenValueFileRD(int pin);
    int gpioOpenValueFileWR(int pin);
    int gpioCloseValueFile(int fd);
    int gpioOnlySetValue(int fd, int value);
    int gpioOnlyReadValue(int fd);
    /***********************************************************************/

private:
    int a;
    int b;
signals:
};

#endif  // GPIO_H
